package com.seedwill.common.meta.db;

import com.seedwill.common.meta.IEventExecutor;
import com.seedwill.common.meta.event.MetaEvent;
import com.seedwill.common.meta.event.MetaEventListener;

/**
 * 
 * DB监控器
 * 
 * @author yikuide@gmail.com
 *
 */
public class XDBMonitor implements MetaEventListener {
	
//	/**
//	 * @param src
//	 * @param event
//	 */
//	public void fireEvent(Object src, MetaEvent event){
//		
//	}
	
	IEventExecutor dbEventExcutor;
	IEventExecutor columnEventExcutor;
	IEventExecutor functionEventExcutor;
	IEventExecutor procedureEventExcutor;
	IEventExecutor keyEventExcutor;
	IEventExecutor tableEventExcutor;
	IEventExecutor viewEventExcutor;
	IEventExecutor triggerEventExcutor;
	IEventExecutor relationShipEventExcutor;
	
	@Override
	public void handleEvent(MetaEvent event) {
		boolean hited = false;
		//
		if(dbEventExcutor.match(event)){
			dbEventExcutor.execute(event);
			hited = true;
		}
		//
		if(columnEventExcutor.match(event)){
			columnEventExcutor.execute(event);
			hited = true;
		}
		//
		if(functionEventExcutor.match(event)){
			functionEventExcutor.execute(event);
			hited = true;
		}
		//
		if(procedureEventExcutor.match(event)){
			procedureEventExcutor.execute(event);
			hited = true;
		}
		//
		if(keyEventExcutor.match(event)){
			keyEventExcutor.execute(event);
			hited = true;
		}
		//
		if(tableEventExcutor.match(event)){
			tableEventExcutor.execute(event);
			hited = true;
		}
		//
		if(viewEventExcutor.match(event)){
			viewEventExcutor.execute(event);
			hited = true;
		}
		//
		if(triggerEventExcutor.match(event)){
			triggerEventExcutor.execute(event);
			hited = true;
		}
		//
		if(relationShipEventExcutor.match(event)){
			relationShipEventExcutor.execute(event);
			hited = true;
		}
		if(!hited){
			//evevt missed fire target
		}
	}
}
